package com.nuoniu.sibanyun.mapper.production;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nuoniu.sibanyun.entity.dto.ErpWorkProcedureCardDetailDto;
import com.nuoniu.sibanyun.entity.production.ErpWorkProcedureCardDetail;
import com.nuoniu.sibanyun.entity.vo.ErpWorkProcedureCardDetailVo;
import com.nuoniu.sibanyun.entity.vo.ProcedureCardDetailVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 工序流转卡明细 Mapper 接口
 * </p>
 *
 * @author 白强
 * @since 2021-03-30
 */
public interface ErpWorkProcedureCardDetailMapper extends BaseMapper<ErpWorkProcedureCardDetail> {


    @Select("SELECT COUNT(id) FROM ma_process_report_datail WHERE company_id = #{companyId} AND account_id = #{accountId} AND production_dispatch_id = #{productionDispatchId}")
    int sumByProductionDispatchId(Integer companyId,Integer accountId,Long productionDispatchId);


    List<ProcedureCardDetailVo> listByIds(Integer companyId,Integer accountId,List<Long> ids);

    List<ProcedureCardDetailVo> listProcedureCardDetailVoMobile(Integer companyId,Integer accountId,Integer workProcedureDetailId);

    /**
     *   根据加工明细但查询 最大的流水号
     * @param companyId
     * @param accountId
     * @param workProcedureDetailId
     * @return
     */
    Integer getMaxSerialNumber(Integer companyId,Integer accountId,Integer workProcedureDetailId);



    Page<ErpWorkProcedureCardDetailVo> pageProductionWorkProcedureDetailVo(Page page,Integer companyId,Integer accountId, @Param("dto") ErpWorkProcedureCardDetailDto erpWorkProcedureCardDetailDto);


    /**
     * @title 通过生产加工单ID 查询 是否汇报
     * @description
     * @author 白强
     * @updateTime 2021/12/27 15:59
     * @throws
     */
    boolean checkWorkReport(Integer companyId,Integer accountId,Long workMainId);

    /**
     * 通过生产加工单明细ID 查询 是否汇报
     * @param companyId
     * @param accountId
     * @param workDetailIds  生产加工单明细ID
     * @return
     */
    boolean checkWorkReportByWorkDetailIds(Integer companyId,Integer accountId,List<Long> workDetailIds);


}
